
module.exports = class admin_dao extends require('../sql/admin_sql'){
    /**
     * 分页获取
     * 根据用户类型和查询字段查询
     * @param req
     * @param resp
     * @returns {Promise<void>}
     */
    static async getUserByTypeChar(req,resp){
        let query = req.query;
        let type = query.type;
        let inputText = query.inputText;
        let CharType = query.CharType;
        let pageNum = query.pageNum;
        let currPage = query.currPage;
        
        let data = await this.getUserByTypeCharMod(type,inputText,CharType,currPage,pageNum)
        let total = await this.getUsersByTypeCharTotal(type,inputText,CharType)
        resp.send({data,total:total[0].count})
    }
    /**
     * 分页获取
     * 模糊查询
     * @param req
     * @param resp
     * @returns {Promise<void>}
     */
    static async getUserData(req,resp){
        let username = req.query.inputText;
        let type = req.query.value;
        let startDate = req.query.startDate;
        let endDate = req.query.endDate;
        let pageNum = req.query.pageNum;
        let currPage =req.query.currPage;
        // console.log(req.query.pageNum)
        let data =await this.getUserDataMod(username,type,startDate,endDate,currPage,pageNum)
        let total=await  this.getUserDataTotal(username,type,startDate,endDate)
        resp.send({data,total:total[0].count})
    }



    static async getMenuData(req,resp){
        let query = req.query;
        let prentId = query.prentId;
        let pageNum = query.pageNum;
        let currPage = query.currPage;

        let data = await this.getMenuDataSql(prentId,currPage,pageNum)
        let total = await this.getMenuDataTotal(prentId)
        resp.send({data,total:total[0].count})
    }
}